

#include <stdio.h>
#include <stdlib.h>

void get_large_number(int n){
	printf("%d\n", n);
	int i, j, *start;
	long size = 1;
	start = malloc(sizeof(int));
	start[0] = 0;
	printf("%p, %d\n", start, start[0]);
	for(i=0; i<=n; i++){
		start[0]++;
		for(j=0; j<size; j++){
			if(start[j]!=10) // if less than 10, then break
				break;
			//if equal 10 on one bit
			start[j] = 0;	// then restore it to 0
			if(j==(size-1)){	// if no enough bit, then malloc a new
				int k, *new;
				new = malloc(size+1);
				for(k=0; k<size-1; k++)
					new[k] = start[k];
				new[size] == 1;
				free(start);
				start = new;
				free(new);
				size++;
				printf("%ld\n", size);
			} else {	// if there is enough bit, then just add 1 to a higher bit
				start[j+1]++;
			}
		} // end for
	} // end for
	printf("%ld\n", size);
	j = size/sizeof(int);

	printf("%ld,%d\n", size,j);
	for(i=j-1; i>=0; i--)
		printf("%d ", start[i]);
	free(start);
}
